'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:TaskWeeklydetailCtrl
 * @description
 * # TaskWeeklydetailCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('TaskWeeklydetailCtrl', function(DataService, openApi, $location, $routeParams, Util) {
        // 初始化
        this.pkId = $routeParams.pkId
        this.subtabindex = 0;
        // 初始化过程
        this.tabList = [{
            value: "工作报告"
        }, {
            value: "查阅情况"
        }, {
            value: "反馈及评论"
        }];
        this.submenuhandle = function(index) {
            if (this.subtabindex == index) {
                return
            }
            this.subtabindex = index;
            switch (index) {
                case 0:
                    this.getweeklyData()
                    break;
                case 1:
                    this.getcheckdData()
                    break;
                case 2:
                    this.getreviewData()
                    break;
            }

        }
        this.getweeklyData = function() {
            var param = {}
            param.pkId = $routeParams.pkId
            param.refId = $routeParams.pkId
            DataService.getData(openApi.getweekDetail, param).then(function(data) {
                this.weeklyData = data
                this.title=data.userName+data.weekOfYear+"周工作周告"
            }.bind(this))

        };
        this.getcheckdData = function() {
            var param = {}
            param.refId = $routeParams.pkId
            DataService.getData(openApi.getworkweeklyHasseenList, param).then(function(data) {
                this.checkedlist = data
            }.bind(this))
        };
        this.getreviewData = function() {
            var param = {}
            param.refId = $routeParams.pkId
                // 获取评论列表
            DataService.getData(openApi.getworkweeklyReviewlist, param).then(function(data) {
                this.reviews = data
            }.bind(this))
        };
        this.initData = function() {
            this.getweeklyData()
        };
        this.initData();
        this.goDetail = function(item) {
            var param = {}
            param.refId = item.pkId;
            DataService.getData(openApi.hasSeenByWorktask, param).then(function(data) {
                console.log(data)
            }.bind(this))
            $location.path("task/taskdetail/" + item.pkId)
        }
    });
